﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class SignUp : System.Web.UI.Page
{
    clsUser objThis = new clsUser();
    string pageName = "User";
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        objThis.Address = txtAddress.Text.Trim();
        objThis.City = txtCity.Text.Trim();
        objThis.Country = txtCountry.Text;
        objThis.CreatedDate = DateTime.Now;
       // objThis.DateOfBirth = Convert.ToDateTime(txtDateOfBirth.Text);
        objThis.Email = txtEmail.Text;
        objThis.FirstName = txtFirstName.Text;
        objThis.IsActive = true;
        objThis.LastName = txtLastName.Text;
        objThis.MiddleName = txtMiddleName.Text;
        objThis.Mobile = txtMobile.Text;
        objThis.Password = txtPassword.Text;
        objThis.Phone = txtPhone.Text;
        objThis.State = txtState.Text;
        objThis.Title = txtTitle.Text;
        objThis.UserName = txtUserName.Text;
        objThis.UserType = 2;
        objThis.Zipcode = txtZipcode.Text;
        if (CommonClass.CheckDuplicateName("tbluser", "UserName", objThis.UserName, objThis.ID, "") == true)
        {
            objThis.ID = CommonClass.AddUpdate(objThis, "User");
            //SendMail(SetEmailParameters(), "Registration.htm", txtEmail.Text, "Confirmation Mail");
            if (objThis.ID != 0)
            {
                if (btnSave.Text == "Update")
                {
                    CommonClass.PrintMessage(litErrorListMsg, "UPDATE,@fieldName-" + pageName);
                }
                else // save
                    CommonClass.PrintMessage(litErrorListMsg, "ADD,@fieldName-" + pageName);


                HttpCookie CookieID = new HttpCookie("CookieMerchantID");
                CookieID["ID"] = objThis.ID.ToString();
                CookieID["UserName"] = objThis.UserName;
                CookieID["UserType"] = "2";
                CookieID.Expires = DateTime.Now.AddDays(30);
                Response.Cookies.Add(CookieID);
               // Response.Redirect("PartnerInfo.aspx");
                // ClearFields();
            }
        }
        else
            CommonClass.PrintError(litErrorListMsg, "DUPLIACTE_FOUND,@fieldName-Username");
    }
}